package org.example.storage.controller;

import org.example.storage.model.StorageTbl;
import org.example.storage.service.StorageTblService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class StorageTblController {

    @Autowired
    private StorageTblService storageTblService;

    //测试请求
    @GetMapping("/storageTest")
    public String storageTest() {
        List<StorageTbl> list = storageTblService.list();
        return "storage中一共有：" + list.size() + "数据";
    }

    @GetMapping("/updateStorage")
    public String update(@RequestParam String commodityCode, @RequestParam Integer count) {
        storageTblService.deduct(commodityCode, count);
        return "更新成功";
    }
}